home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-10-05 | 5.6 KB | 311 lines | [TEXT/MMCC] |
- // CAdd.cp -- dialog methods
- // Created 10/5/95 4:49 PM by AppMaker
-
- #include "CAdd.h"
-
- #include <UReanimator.h>
- #include <URegistrar.h>
- #include <LStream.h>
- #include <LStdControl.h>
- #include <LTabGroup.h>
- #include <LEditField.h>
- #include <LView.h>
- #include <LRadioGroup.h>
- #include <PP_Messages.h>
- #include "CmdCodes.h"
-
- #define PPob_AddID 201
- #define RidL_AddID 201
-
- Boolean CAdd::sIsRegistered = false;
-
- //----------
- void
- CAdd::RegisterClass ()
- {
- URegistrar::RegisterClass('Add ', (ClassCreatorFunc)CAdd::CreateAddStream);
-
- // register the pane classes we use
-
- sIsRegistered = true;
- }
-
- //----------
- CAdd*
- CAdd::CreateAdd(
- LCommander *inSuperCommander)
- {
- if (!sIsRegistered) {
- RegisterClass ();
- }
- return ((CAdd *)LWindow::CreateWindow(PPob_AddID, inSuperCommander));
- }
-
- //----------
- // This is the function you register with URegistrar to create a
- // CAdd from a resource
- CAdd*
- CAdd::CreateAddStream(
- LStream *inStream)
- {
- return (new CAdd(inStream));
- }
-
- //----------
- // The default constructor does nothing.
- CAdd::CAdd()
- {
- }
-
- //----------
- // The read-from-stream constructor just reads a dialog object.
- CAdd::CAdd(
- LStream *inStream)
- : LDialogBox(inStream)
- {
- }
-
- //----------
- // The destructor does nothing.
- CAdd::~CAdd()
- {
- }
-
- //----------
- // This member function gets called once the containment hierarchy that contains
- // this pane has been built. It gives us a chance to get data members for
- // interesting subviews, and to do other operations now that our subviews exist.
- void
- CAdd::FinishCreateSelf()
- {
- LDialogBox::FinishCreateSelf();
-
- mOKButton = (LStdButton *)FindPaneByID('OK ');
- mCancelButton = (LStdButton *)FindPaneByID('Canl');
- mDateField = (LEditField *)FindPaneByID('Dat2');
- mTimeField = (LEditField *)FindPaneByID('Tim2');
- mAmPmView = (LView *)FindPaneByID('AMPM');
- mMessageField = (LEditField *)FindPaneByID('Msg ');
- mDisplayIconCheck = (LStdCheckBox *)FindPaneByID('Icon');
- mDisplayAlertCheck = (LStdCheckBox *)FindPaneByID('Alrt');
- mPlaySoundCheck = (LStdCheckBox *)FindPaneByID('Play');
- mSoundPopup = (LStdPopupMenu *)FindPaneByID('Soun');
-
- mAmPmGroup = new LRadioGroup();
- mAmPmGroup->AddRadio((LStdRadioButton *)mAmPmView->FindPaneByID(1));
- mAmPmGroup->AddRadio((LStdRadioButton *)mAmPmView->FindPaneByID(2));
-
- LTabGroup *tabGroup = new LTabGroup(this);
- mDateField->SetSuperCommander(tabGroup); // becomes the active field
- mTimeField->SetSuperCommander(tabGroup);
- mMessageField->SetSuperCommander(tabGroup);
-
- UReanimator::LinkListenerToControls(this, this, RidL_AddID);
- // the purpose is to "connect" self to whatever controls
- // that we want to "listen" to
-
- // any additional initialization for your dialog:
-
- }
-
- //----------
- void
- CAdd::ListenToMessage(
- MessageT inMessage,
- void *ioParam)
- {
- switch (inMessage) {
- case msg_OK:
- GetSuperCommander()->ProcessCommand(cmd_Add, this);
- break;
-
- case msg_Cancel:
- DoClose();
- break;
-
- default:
- break;
- }
- }
-
- //----------
- Boolean
- CAdd::ObeyCommand(
- CommandT inCommand,
- void *ioParam)
- {
- Boolean cmdHandled = true;
-
- switch (inCommand) {
-
- // +++ Add cases here for the commands you handle
- // Remember to add same cases to FindCommandStatus below
- // to enable/disable the commands
-
- default:
- cmdHandled = LDialogBox::ObeyCommand(inCommand, ioParam);
- break;
- }
-
- return cmdHandled;
- }
-
- //----------
- void
- CAdd::FindCommandStatus(
- CommandT inCommand,
- Boolean &outEnabled,
- Boolean &outUsesMark,
- Char16 &outMark,
- Str255 outName)
- {
- outUsesMark = false;
-
- switch (inCommand) {
-
- // +++ Add cases here for the commands you handle
-
- default:
- LDialogBox::FindCommandStatus(inCommand, outEnabled,
- outUsesMark, outMark, outName);
- break;
- }
- }
-
- //----------
- Boolean
- CAdd::FocusDraw()
- {
- Boolean focused = LView::FocusDraw();
-
- if (focused) {
- AuxWinHandle awHndl;
- CTabHandle awCTable;
- ColorSpec contentSpec;
-
- GetAuxWin(GetMacPort(), &awHndl);
- awCTable = (**awHndl).awCTable;
- contentSpec = (**awCTable).ctTable [wContentColor]; // should search vs. index
- ::RGBBackColor(&contentSpec.rgb);
- }
-
- return focused;
- }
-
- //----------
- void
- CAdd::GetDateFieldString (Str255 str)
- {
- mDateField->GetDescriptor(str);
- }
-
- //----------
- void
- CAdd::SetDateFieldString (Str255 str)
- {
- mDateField->SetDescriptor(str);
- }
-
- //----------
- void
- CAdd::GetTimeFieldString (Str255 str)
- {
- mTimeField->GetDescriptor(str);
- }
-
- //----------
- void
- CAdd::SetTimeFieldString (Str255 str)
- {
- mTimeField->SetDescriptor(str);
- }
-
- //----------
- long
- CAdd::GetAmPmGroupChoice()
- {
- return mAmPmGroup->GetCurrentRadioID();
- }
-
- //----------
- void
- CAdd::SetAmPmGroupChoice (long choice)
- {
- LControl *theControl = (LControl *)mAmPmView->FindPaneByID(choice);
-
- if (theControl != nil) {
- theControl->SetValue(Button_On);
- }
- }
-
- //----------
- void
- CAdd::GetMessageFieldString (Str255 str)
- {
- mMessageField->GetDescriptor(str);
- }
-
- //----------
- void
- CAdd::SetMessageFieldString (Str255 str)
- {
- mMessageField->SetDescriptor(str);
- }
-
- //----------
- Boolean
- CAdd::GetDisplayIconCheckChoice()
- {
- return mDisplayIconCheck->GetValue();
- }
-
- //----------
- void
- CAdd::SetDisplayIconCheckChoice (Boolean choice)
- {
- mDisplayIconCheck->SetValue(choice);
- }
-
- //----------
- Boolean
- CAdd::GetDisplayAlertCheckChoice()
- {
- return mDisplayAlertCheck->GetValue();
- }
-
- //----------
- void
- CAdd::SetDisplayAlertCheckChoice (Boolean choice)
- {
- mDisplayAlertCheck->SetValue(choice);
- }
-
- //----------
- Boolean
- CAdd::GetPlaySoundCheckChoice()
- {
- return mPlaySoundCheck->GetValue();
- }
-
- //----------
- void
- CAdd::SetPlaySoundCheckChoice (Boolean choice)
- {
- mPlaySoundCheck->SetValue(choice);
- }
-
- //----------
- short
- CAdd::GetSoundPopupChoice()
- {
- return mSoundPopup->GetValue();
- }
-
- //----------
- void
- CAdd::SetSoundPopupChoice (short choice)
- {
- mSoundPopup->SetValue(choice);
- }
-
-